<template>
  <div class="WorkingSchedule" v-loading="loading">
    <el-form ref="form" :model="form" label-position="top" class="myform">
      <div>
        <el-form-item label="加工单号" class="myform-item">
          <el-input
            v-model="form.processing_code"
            placeholder="请输入加工单号"
            @keyup.enter.native="onSearch"
            clearable
          ></el-input>
        </el-form-item>
        <el-form-item label="sku" class="myform-item">
          <el-input
            v-model="form.sku_code"
            @keyup.enter.native="onSearch"
            placeholder="请输入sku"
            clearable
          ></el-input>
        </el-form-item>
      </div>
      <div>
        <el-form-item style="margin-top: 50px">
          <el-button type="primary" @click="onSearch">查询</el-button>
          <!-- <el-button type="primary">导出</el-button>
          <el-button type="primary">上传文件</el-button> -->
        </el-form-item>
      </div>
    </el-form>
    <el-table :data="tableData" style="width: 100%" border>
      <el-table-column label="工厂名" align="center" prop="factory_name">
      </el-table-column>
      <el-table-column
        label="成品加工单编码"
        align="center"
        prop="processing_code"
      >
      </el-table-column>
      <el-table-column label="SKU编码" align="center" prop="sku_code">
      </el-table-column>
      <el-table-column label="款名" align="center" prop="type_name">
      </el-table-column>
      <el-table-column label="款号" align="center" prop="type_no">
      </el-table-column>
      <el-table-column label="颜色编码" align="center" prop="color_code">
      </el-table-column>
      <el-table-column label="尺码编码" align="center" prop="size_code">
      </el-table-column>
      <el-table-column label="添加时间" align="center" prop="createtime">
      </el-table-column>
      <el-table-column label="增裁数量" align="center" prop="num">
      </el-table-column>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="{ row }">
          <div
            :style="{
              color: row.status == 1 ? '#67C23A' : row.status == 3 ? 'red' : '',
            }"
          >
            {{
              row.status == 0 ? "待审批" : row.status == 1 ? "已通过" : "未通过"
            }}
          </div>
        </template>
      </el-table-column>
      <el-table-column label="创建人" align="center" prop="adduser">
      </el-table-column>
    </el-table>
    <pagination
      :form="form"
      :total="total"
      @paginationPostOrderTaskList="postAdminCodeGetshenqinglist"
    />
  </div>
</template>

<script>
import { postAdminCodeGetshenqinglist } from "@/api";
import pagination from "@/components/pagination.vue";
export default {
  components: { pagination },
  data() {
    return {
      loading: false,
      form: {
        processing_code: "",
        sku_code: "",
        page: 1,
        size: 10,
      },
      tableData: [],
      total: 1,
    };
  },
  activated() {
    let form = this.form;
    this.postAdminCodeGetshenqinglist(form);
  },
  methods: {
    // 查看
    onLook(id) {
      this.$router.push({ name: "QCRecord", query: { id } });
    },
    // 编辑
    onEdit(e) {
      console.log("编辑", e);
      this.detail = e;
      this.dialogVisible = true;
    },
    // qc列表
    async postAdminCodeGetshenqinglist(data) {
      this.loading = true;
      this.form = data;
      let form = JSON.parse(JSON.stringify(this.form));
      if (form.qc_time) {
        form.qc_time = `${form.qc_time[0]}/${form.qc_time[1]}`;
      }
      postAdminCodeGetshenqinglist(form)
        .then((res) => {
          this.loading = false;
          console.log("qc列表", res);
          this.tableData = res.data;
          this.total = Number(res.total);
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    // 搜索
    onSearch() {
      this.form.page = 1;
      this.form.size = 10;
      this.postAdminCodeGetshenqinglist(this.form);
    },
  },
};
</script>

<style lang="scss" scoped>
.myform {
  display: flex;
  justify-content: space-between;
  > div {
    display: flex;
  }
  &-item {
    margin-right: 10px;
  }
}
.WorkingSchedule {
  background: #ffff;
  padding: 20px;
  border-radius: 2px;
  @include boxShadow;
}
</style>
